import logging

from logtools.logtools import logfile_hander, console_handler
from Tools.peeweeTools.mysqlConnect import db_instance

logger = logging.getLogger(__name__)
logger.setLevel(level=logging.INFO)
# logger.root.setLevel(level=logging.INFO)
logger.addHandler(logfile_hander())
logger.addHandler(console_handler())

db_instance.execute_sql("use neirongdb;")
cursor = db_instance.execute_sql("SELECT * FROM `neirongdb`.`nrlj_big_table_split_info`;")
rows = cursor.fetchall()
for row in rows:
    logger.info(row[1])
db_instance.close()

# db = SqliteDatabase('people.db')
# db.connect()
#
# sql = "INSERT INTO person (id, name, birthday) VALUES (?,?,?)"
# params = ("7", "Doe", "1960-01-15")
#
# db.execute_sql(sql, params)
#
# sql_query = "select * from person"
#
# cursor = db.execute_sql(sql_query)
# for row in cursor.fetchall():
#     print(row)
#
# cursor = db.execute_sql(sql_query)
# res = cursor.fetchone()
# print(res)
# print('Total: ', res[0])
#
# db.close()
